//
//  GradientButton.m
//  Meal4iOS
//
//  Created by Jaedong n.Die_ on 12-8-21.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "GradientButton.h"

@implementation GradientButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)didMoveToSuperview {

    [super didMoveToSuperview];
    
    _unselectLayer = [CAGradientLayer layer];
    _unselectLayer.frame = self.bounds;
    _unselectLayer.cornerRadius = 5.0f;
    _unselectLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f], [NSNumber numberWithFloat:1.0f], nil];
    _unselectLayer.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.35f] CGColor],
                             (id)[[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.1f] CGColor], nil];
    
    UIGraphicsBeginImageContext(self.bounds.size);
    CGContextRef c = UIGraphicsGetCurrentContext();
    [_unselectLayer renderInContext:c];
    UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    [self setBackgroundImage:viewImage forState:UIControlStateNormal];
}


@end
